import { NoSkinCellRenderer } from "../../common/item/NoSkinCellRenderer";
import { SLadderToplist } from "../../../../../Message/Public/SLadderToplist";
import { Cache } from "../../../cache/Cache";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { EntityUtil } from "../../../scene/layer/utils/EntityUtil";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { ObjCreate } from "../../common/ObjCreate";
import { ImagesConst } from "../../../resource/ImagesConst";
import { GTextFiledBitmap } from "../../../../../com/mui/controls/GTextFiledBitmap";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
//class LadderBattlefieldRankingRenderer
    
    export  class LadderBattlefieldRankingRenderer extends NoSkinCellRenderer
    {
        constructor()
        {
            super();
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            super.data = arg1;
            if (typeof arg1 === "sladdertoplist") 
            {
                this._vo = arg1 as SLadderToplist;
                this._ranking.text = this._vo.rankCross.toString();
                this._winRate.text = Math.floor(this._vo.winPer / 100) + "%";
                this._leftPer.text = this._vo.lifePer / 100 + "%";
                this._integral.text = this._vo.mark.toString();
                if (this._vo.entityId.id != Cache.instance.role.entityInfo.entityId.id) 
                {
                    this._name.htmlText = HTMLUtil.addLink(EntityUtil.getProxyName(this._vo.entityId) + " " + this._vo.name, GlobalStyle.color1);
                }
                else 
                {
                    this._name.htmlText = HTMLUtil.addLink(EntityUtil.getProxyName(this._vo.entityId) + " " + this._vo.name, GlobalStyle.color5);
                }
                if (this._name.defaultTextFormat.align != flash.text.TextFormatAlign.CENTER) 
                {
                    this._name.defaultTextFormat.align = flash.text.TextFormatAlign.CENTER;
                }
            }
            return;
        }

        /* internal  */onLinkHandler(arg1: Object /* flash.events.TextEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.PlayerInfo_view, this._vo.entityId));
            return;
        }

        protected /* override */ createChildren(): void
        {
            var loc1=GlobalStyle.setTextFormatAlign(GlobalStyle._textFormat1, flash.text.TextFormatAlign.CENTER);
            this._ranking = ObjCreate.createGTextFiledBitmap("", 0, 5, 60, 20, this, loc1);
            this._name = ObjCreate.createGTextField("", 60, 5, 180, 20, this, loc1);
            this._winRate = ObjCreate.createGTextFiledBitmap("", 240, 5, 40, 20, this, loc1);
            this._leftPer = ObjCreate.createGTextFiledBitmap("", 280, 5, 70, 20, this, loc1);
            this._integral = ObjCreate.createGTextFiledBitmap("", 350, 5, 70, 20, this, loc1);
            ObjCreate.createBg(9, 25, 410, 2, this, ImagesConst.SplitLine);
            this._name.addEventListener(flash.events.TextEvent.LINK, this.onLinkHandler);
            return;
        }

        /* internal */ /* var */_ranking: GTextFiledBitmap;

        /* internal */ /* var */_name: GTextFiled;

        /* internal */ /* var */_winRate: GTextFiledBitmap;

        /* internal */ /* var */_leftPer: GTextFiledBitmap;

        /* internal */ /* var */_integral: GTextFiledBitmap;

        /* internal */ /* var */_vo: SLadderToplist;
    }
